package tools;

import java.util.StringTokenizer;


public class Parser {

    public static String parse(String toParse, String operator) {
        StringTokenizer tokens = new StringTokenizer(toParse);
        String partial = "";
        String separator = " " + operator + " ";
        
        while(tokens.hasMoreTokens()) {
            partial += " " + tokens.nextToken();
        }
        
        partial = partial.replace(" ", separator);

        if (!operator.equals(GlobalVariables.NOT)) {
            partial = partial.substring(separator.length()-1); // Eliminar el primer: " " + operator + " "
        }

        return partial.trim();
    }

}
